package com.ljkj.common.db.dao;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ljkj.access.Tright;
import com.ljkj.common.db.basedao.BaseDAO;

public class TrightDAO extends BaseDAO {
	
	private static final Logger log = LoggerFactory.getLogger(TrightDAO.class);

	

	public Tright findById(java.lang.Integer id) {
		log.debug("getting Tright instance with id: " + id);
		try {
			Tright instance = (Tright) getHibernateTemplate().get(
					"com.ljkj.access.Tright", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public List findByProperty(String propertyName, Object value) {
		log.debug("finding Tright instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from Tright as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}
	
	public void save(Tright transientInstance) {
		log.debug("saving Tright instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public void update(Object object) {
		log.debug("updating " + object + " instances");
		try {
			getHibernateTemplate().saveOrUpdate(object);
			log.debug("update successful");
		} catch (RuntimeException re) {
			log.error("update failed", re);
			throw re;
		}
	}
	
}
